home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 7524 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.6 KB

  1. Path: newshost.lanl.gov!tanmoy
  2. From: tanmoy@qcd.lanl.gov (Tanmoy Bhattacharya)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: How do I modify a character string that's declared as an array of char?
  5. Date: 26 Feb 1996 03:37:54 GMT
  6. Organization: Los Alamos National Laboratory
  7. Distribution: world
  8. Message-ID: <TANMOY.96Feb25203754@qcd.lanl.gov>
  9. References: <4gj2nl$840@mirzam.usc.edu> <4gqo63$2pr@newshost.cyberramp.net>
  10. NNTP-Posting-Host: qcd.lanl.gov
  11. Mime-Version: 1.0
  12. Content-Type: text
  13. In-reply-to: sinan@cyberramp.net's message of 25 Feb 1996 22:34:43 GMT
  14.  
  15. In article <4gqo63$2pr@newshost.cyberramp.net>
  16. sinan@cyberramp.net (John Noland) writes:
  17.  
  18. JN: >   char mydata[50];
  19. JN: >
  20. JN: >   strcpy(mydata,"test string");
  21. JN: >   myfunction(&mydata);
  22. JN:                ^ 
  23. JN: Dereferencing mydata isn't necessary. mydata is a pointer to the first 
  24. JN: character of your array, so what you're really doing is passing a pointer
  25. JN: to that pointer.
  26.  
  27. Wrong. mydata is an array that usually decays to a pointer to the
  28. first character. One place where it does not decay is when it is the
  29. operand of &. &mydata is a pointer to the entire array. Read the FAQ
  30. for more details.
  31.  
  32. Cheers
  33. Tanmoy
  34. --
  35. tanmoy@qcd.lanl.gov(128.165.23.46) DECNET: BETA::"tanmoy@lanl.gov"(1.218=1242)
  36. Tanmoy Bhattacharya O:T-8(MS B285)LANL,NM87545 H:#9,3000,Trinity Drive,NM87544
  37. Others see <gopher://yaleinfo.yale.edu:7700/00/Internet-People/internet-mail>,
  38. <http://alpha.acast.nova.edu/cgi-bin/inmgq.pl>or<ftp://csd4.csd.uwm.edu/pub/
  39. internetwork-mail-guide>. -- <http://nqcd.lanl.gov/people/tanmoy/tanmoy.html>
  40. fax: 1 (505) 665 3003   voice: 1 (505) 665 4733    [ Home: 1 (505) 662 5596 ]
  41.